const mongoose = require("./db")
const roleSchema = new mongoose.Schema({
    rname: String,
    system: {
        type: [String],
        default: []
    }
})

const roleModel = mongoose.model("role", roleSchema, "role")

const userSchema = new mongoose.Schema({
    userName:String,
    passWord:String,
    phone:String,
    rid:Number,
    imgSrc:String
})
const userModel = mongoose.model('user',userSchema,'user')

// 教师数据
let teacherSchema = new mongoose.Schema({
    id: Number,//编号
    name: String,//姓名
    sex: String,//性别
    document: {
        type: mongoose.Types.ObjectId,
        ref: 'document'
    },//证件类型
    number: String,//证件号码
    school: {
        type: String,
        default: '新学道测试学院'
    },//学校
    phone: String,//联系方式
    emait: String,//邮箱
    start_time: {
        type: Date,
        default: new Date()
    },//创建时间
    staut: {
        type: Number,
        default: 1
    },//任职状态
    ori: String,//籍贯
    discipline: {
        type: mongoose.Types.ObjectId,
        ref: 'discipline'
    },//学科
    post: {
        type: mongoose.Types.ObjectId,
        ref: 'post'
    },//岗位
    class: {
        type: mongoose.Types.ObjectId,
        ref: 'class'
    },//班级
    grade: {
        type: mongoose.Types.ObjectId,
        ref: 'grade'
    }//年级
})
let studentSchema = new mongoose.Schema({
    id: Number,//编号
    name: String,//姓名
    sex: String,//性别
    snumber:Number,//学号
    document: {
        type: mongoose.Types.ObjectId,
        ref: 'document'
    },//证件类型
    number: String,//证件号码
    school: {
        type: String,
        default: '新学道测试学院'
    },//学校
    father:String,//父亲
    fphone: String,//父亲联系方式
    mother:String,//母亲
    mphone:String,//母亲联系方式
    start_time: {
        type: Date,
        default: new Date()
    },//创建时间
    staut: {
        type: Number,
        default: 1
    },//系统状态
    ori: String,//籍贯
    class: {
        type: mongoose.Types.ObjectId,
        ref: 'class'
    },//班级
    grade: {
        type: mongoose.Types.ObjectId,
        ref: 'grade'
    }//年级
})
let banjiSchema= new mongoose.Schema({
    id:Number,
    class: {
        type: mongoose.Types.ObjectId,
        ref: 'class'
    },//班级
    grade: {
        type: mongoose.Types.ObjectId,
        ref: 'grade'
    },//年级
    term:{
        type: mongoose.Types.ObjectId,
        ref: 'term'
    },//学段
    ca:{
        type: mongoose.Types.ObjectId,
        ref: 'teacher'
    },//班主任
    type:{
        type: mongoose.Types.ObjectId,
        ref: 'type'
    }//班级类型
})
let termSchema=new mongoose.Schema({
    term:String
})//学段
let typeSchema=new mongoose.Schema({
    type:String
})//班级类型
let documentSchema = new mongoose.Schema({
    document: String
})//证件类型
let disciplineSchema = new mongoose.Schema({
    discipline: String
})//学科
let postSchema = new mongoose.Schema({
    post: String
})//岗位
let classSchema = new mongoose.Schema({
    class: String
})//班级
let gradeSchema = new mongoose.Schema({
    grade: String
})//年级

let teacherModel = mongoose.model('teacher', teacherSchema, 'teacher')
let studentModel = mongoose.model('student', studentSchema, 'student')
let documentModel = mongoose.model('document', documentSchema, 'document')
let disciplineModel = mongoose.model('discipline', disciplineSchema, 'discipline')
let postModel = mongoose.model('post', postSchema, 'post')
let classModel = mongoose.model('class', classSchema, 'class')
let gradeModel = mongoose.model('grade', gradeSchema, 'grade')
let banjiModel = mongoose.model('banji', banjiSchema, 'banji')
let termModel = mongoose.model('term', termSchema, 'term')
let typeModel = mongoose.model('type', typeSchema, 'type')

let PreparingSchema=new mongoose.Schema({
    semester:String,//班级
    grade:String,//年级
    discipline:String,//学科
    version:String,//版本
    volume:String,//册次
    course:String,//教学章节
    knowledge:String,//涉及知识点
    name:String,//备课名称
    bktype:String,//备课类型
    file:String,//上传文件
    teacher:String,//教师名称
    audit:{
        type:String,
        default:'待审核'
    },//审核
    quality:String,//备课质量
    data:String,//备课时间
    instance:{//实例
        type:Boolean,
        default:false
    },
    source:String,//来源
})

let PreparingModel=mongoose.model('preparing',PreparingSchema,'preparing')

//zpl
let HomeworkSchema = new mongoose.Schema({
    name:String,         //作业名称
    starttime: String,   //开始时间
    endtime: String,     //结束时间
    discipline: String,  //学科
    semester: String,    //学段
    grade:String,        //年级
    age:String,          //班级
    teacher:String,      //班级老师

})
let HomeworkModel=mongoose.model('homework',HomeworkSchema,'homework')

let topicSchema = new mongoose.Schema({
    ti: String,
    liang:Number
  
})
let topicModel = mongoose.model('topic', topicSchema, 'topic')

let zhengSchema = new mongoose.Schema({
    zheng: String,
    liang:Number
  
})
let zhengModel=mongoose.model('zheng',zhengSchema,'zheng')





module.exports = {
    roleModel,
    teacherModel,
    documentModel,
    disciplineModel,
    postModel,
    classModel,
    gradeModel,
    PreparingModel,
    userModel,
    studentModel,
    banjiModel,
    termModel,
    typeModel,
    HomeworkModel,
    topicModel,
    zhengModel

}







